<style>
    .table>tbody>tr>td{vertical-align: middle;}
</style>
<div id="page-wrapper">
    <div class="row">
        <div class="col-lg-12">
            <h3 class="page-header">
                <span>数据统计</span>
            </h3>
        </div>
    </div>
    <div class="row">
        <div class="col-lg-12">
            <div class="panel panel-default">
                <div class="panel-heading">
                    <ul class="nav nav-tabs" id="myTab">
                        <li><a href="/User/Live/statistics?topic_id={$topic_id}">总概</a></li>
                        <li class="active"><a href="javascript:;">用户行为</a></li>
                    </ul>
                </div>
                <div class="panel-body">
                    <div class="form-horizontal">
                        <div class="tab-content">
                            <div class="tab-pane active">
                                <div class="panel-heading">
                                    <a href="javascript:;" id="deleteAll" class="btn btn-success">删除</a>
                                    <button style="float:right" type="button" onclick="return download();" class="btn btn-info">导出</button>
                                </div>
                                <div class="panel-body">
                                    <div class="table-responsive">
                                        <table class="table table-bordered">
                                            <thead>
                                            <tr>
                                                <th width="5%"><input type="checkbox" id="selectAll"></th>
                                                <th width="5%">编号</th>
                                                <th width="20%">时间</th>
                                                <th width="20%">openid</th>
                                                <th width="10%">是否评论</th>
                                                <th width="10%">地域</th>
                                                <th width="20%">手机型号</th>
                                                <th>操作</th>
                                            </tr>
                                            </thead>
                                            <tbody>
                                            <volist name="list" id="item">
                                                <tr>
                                                    <td><input type="checkbox" name="ids" value="{$item.id}"></td>
                                                    <td>{$item.id}</td>
                                                    <td>{$item.createdate}</td>
                                                    <td>{$item.openid}</td>
                                                    <td>{$item.has_comment}</td>
                                                    <td>{$item.area}</td>
                                                    <td>{$item.phone_type}</td>
                                                    <td>
                                                        <a type="button" href="javascript:;" onclick="statusMember({$item['id']}, 'delete');" class="btn btn-danger">删除</a>
                                                    </td>
                                                </tr>
                                            </volist>
                                            </tbody>
                                        </table>
                                    </div>
                                    <div class="pages">
                                        {$page}
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    $(function () {
        $('#myTab a:eq(1)').tab('show');
    })

    $("#selectAll").click(function(){
        if($(this).prop('checked') == true){
            $("input[name=ids]").prop('checked',true);
        }else{
            $("input[name=ids]").prop('checked',false);
        }
    })

    $("#deleteAll").click(function(){
        if(!confirm('确认删除吗？')) return false;
        var ids = "";
        $("input[name=ids]").each(function() {
            if($(this).prop("checked")){
                ids += $(this).val() + "|";
            }
        });
        if(ids != ''){
            $.ajax({
                data: {ids: ids},
                dataType: 'json',
                url: '/User/Live/deleteMember',
                type: 'get',
                success: function (res) {
                    alert(res['info']);
                    window.location.reload();
                }
            });
        }else{
            alert('请勾选一项！');
        }
    });

    function statusMember(id, status){
        if(!confirm('确认删除吗？')) return false;
        $.ajax({
            data: {id: id, status: status},
            dataType: 'json',
            url: '/User/Live/statusMember',
            type: 'get',
            success: function (res) {
                alert(res['info']);
                window.location.reload();
            }
        });
        return false;
    }

    function download(){
        var topic_id = '<?php echo $topic_id; ?>';
        window.location = '/User/Live/exportMember?topic_id=' + topic_id;
        return false;
    }
</script>